﻿var AdControllers = angular.module('AdControllers', []);



AdControllers.controller('AdCtrl', ['$scope', '$http', '$resource', function ($scope, $http, $resource) {
    $http.get('/api/ad').success(function (data) {

        $scope.name = data.name;
        
         $scope.groups = data.groups;
        


    }).error(function (data, status, headers, config) {
        $scope.name = "Oops... something went wrong";
    
});

    $scope.sendAnswer = function () {
        $scope.name = 'true';
    


        $http.post('/api/user', { 'users': $scope.productSelection }).success(function (data, status, headers, config) {
            $scope.name = (data === "true");
    
        }).error(function (data, status, headers, config) {
            $scope.name = "Oops... something went wrong";
    
        });
    };


    $scope.selectAction = function () {
        $scope.name = $scope.currentGroup;
        $scope.productSelection = [3, 5];

        $http.get("/api/user").success(function (data, status, headers, config) {
            $scope.users = data;
            
            
            

        }).error(function (data, status, headers, config) {
            $scope.name = "Oops... something went wrong";
            
        });
    };

}])